﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Student
{
    class Student : ICloneable, IComparable<Student>
    {
        public string Name { get; set; }
        public string SSN { get; set; }
        public string Address { get; set; }
        public string PhoneNumber { get; set; }
        public string Email { get; set; }
        public Universities University { get; set; }
        public Faculties Faculty { get; set; }
        public Courses Course { get; set; }

        public int CompareTo(Student other)
        {
            if (this.Name.CompareTo(other.Name) == 0)
            {
                return this.SSN.CompareTo(other.SSN);
            }
            return 0;
        }

        object ICloneable.Clone()
        {
            return this.Clone();
        }

        public Student Clone()
        {
            Student clone = new Student();
            clone.Name = (string)this.Name.Clone();
            clone.SSN = (string)this.SSN.Clone();
            clone.Address = (string)this.Address.Clone();
            clone.PhoneNumber = (string)this.PhoneNumber.Clone();
            clone.Email = (string)this.Email.Clone();
            clone.University = this.University;
            clone.Faculty = this.Faculty;
            clone.Course = this.Course;
            return clone;
        }

        public override bool Equals(object obj)
        {
            Student other = obj as Student;
            if (other == null)
            {
                return false;
            }
            return this.SSN.Equals(other.SSN);
        }

        public override string ToString()
        {
            return string.Format("{0} {1} {2} {3} {4} {5} {6} {7}", Name, SSN, Address, PhoneNumber,
                Email, University, Faculty, Course);
        }

        public override int GetHashCode()
        {
            return SSN.GetHashCode();
        }

        public static bool operator ==(Student first, Student second)
        {
            return first.Equals(second);
        }

        public static bool operator !=(Student first, Student second)
        {
            return !first.Equals(second);
        }
    }
}
